<?php

namespace App\Admin\Form\Field;

use App\Admin\Form\Field;

class Text extends Field
{
    use PlainInput;

    protected $default = '';

    /**
     * @inheritdoc
     */
    public function render()
    {
        $this->initPlainInput();

        $this->defaultAttribute('type', 'text')
             ->defaultAttribute('id', $this->id)
             ->defaultAttribute('name', $this->elementName ?: $this->formatName($this->column))
             ->defaultAttribute('value', old($this->column, $this->value()))
             ->defaultAttribute('class', 'layui-input ' . $this->getElementClassString())
             ->defaultAttribute('placeholder', $this->getPlaceholder());

        return parent::render()->with([
            'prepend' => $this->prepend,
            'append'  => $this->append,
        ]);
    }
}